#ifndef ENUMLIST_H
#define ENUMLIST_H

#include <QObject>
#include <QtCore/QStringList>
#include <QtCore/QMetaEnum>

class EnumList : public QObject
{
    Q_OBJECT

    Q_ENUMS(TestEnumA)
    //!use Q_ENUMS to make TestEnumA enum name
    // be able to read by meta-data object

    Q_ENUMS(TestEnumB)
    //!use Q_ENUMS to make TestEnumB enum name
    // be able to read by meta-data object

public:
    enum TestEnumA {
        TEST_ENUM_A_INDEX0 = 0x10000000U,
        TEST_ENUM_A_INDEX1 = 0x10011001U,
        TEST_ENUM_A_INDEX2 = 0x20022002U,
        TEST_ENUM_A_INDEX3 = 0x30033003U,
        TEST_ENUM_A_INDEX4 = 0x40044004U,
        TEST_ENUM_A_INDEX5 = 0x50055005U
    };

    enum TestEnumB {
        TEST_ENUM_B_INDEX0 = 1000,
        TEST_ENUM_B_INDEX1,
        TEST_ENUM_B_INDEX2,
        TEST_ENUM_B_INDEX3,
        TEST_ENUM_B_INDEX4,
        TEST_ENUM_B_INDEX5,
        TEST_ENUM_B_INDEX6,
        TEST_ENUM_B_INDEX7,
        TEST_ENUM_B_INDEX8,
        TEST_ENUM_B_INDEX9
    };

    explicit EnumList(QObject *parent = 0)
        : QObject(parent){}


    QMetaEnum getMetaEnum(const char *enumName)
    {
        QMetaEnum metaEnum;

        int enumIndex = metaObject()->indexOfEnumerator(enumName);
        metaEnum = metaObject()->enumerator(enumIndex);

        return metaEnum;
    }

    QStringList getEnumNameList(const char *enumName)
    {
        QMetaEnum metaEnum;
        QStringList enumNameList;

        int enumIndex = metaObject()->indexOfEnumerator(enumName);
        metaEnum = metaObject()->enumerator(enumIndex);

        for (int i=0; i<metaEnum.keyCount(); ++i)
        {
            enumNameList << metaEnum.key(i);
        }

        qDebug("*******************************************");
        qDebug("EnumList::%s enum list output start", enumName);
        for (int i=0; i<enumNameList.length(); ++i)
        {
            QByteArray byteArray = enumNameList[i].toLocal8Bit();
            qDebug("%s", byteArray.data());
        }
        qDebug("*******************************************");

        return enumNameList;
    }

};

#endif // ENUMLIST_H
